package ticketdao

import (
	"fmt"
	"yundian/internel/app/helper/request"
	"yundian/internel/app/models/ticketmodel"
	"yundian/internel/pkg/dingo"
	"yundian/internel/pkg/dingo/global"
)

func (d *TicketDao) GetTicketTipsList(param *request.BaseListReq) *dingo.ErrorWrap {
	var (
		lst    []*ticketmodel.TicketTipsModel
		count  int64
		limit  int = param.PageSize
		offset int = param.PageSize * (param.PageNo - 1)
	)

	db := global.Orm.Table(fmt.Sprintf(`%s `, ticketTips))

	db.Order("id DESC")
	db.Limit(limit).Offset(offset).Find(&lst).Offset(-1).Limit(-1).Count(&count)
	return dingo.ErrorIf(db.Error, lst, count)
}
